package mae.app;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

/**
 * Class for the creation and updating of the Superhero Table.
 * @author DJ
 *
 */
public class SuperheroTable {
	// Database creation SQL statement
	private static final String DATABASE_CREATE = "create table Superhero "
			+ "(_id integer primary key autoincrement, "
			+ "Name text not null, " + "Year text not null, "
			+ "Value text not null, " + "Status text not null);";

	/**
	 * Method for the creation of the Superhero Table  via the 
	 * DATABASE_CREATE string 
	 * @param database // a SQLite database
	 */
	public static void onCreate(SQLiteDatabase database) {
		database.execSQL(DATABASE_CREATE);
	}

	/**
	 * Method for the updating of the Superhero Table, will drop table
	 * if exists, calls onCreate method.
	 * @param database // a SQLite database
	 * @param oldVersion // an int describing the oldVersion of the database
	 * @param newVersion // an int describing the newVersion of the database
	 */
	public static void onUpgrade(SQLiteDatabase database, int oldVersion,
			int newVersion) {
		Log.w(SuperheroTable.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
						+ newVersion + ", which will destroy all old data");
		database.execSQL("DROP TABLE IF EXISTS Superhero");
		onCreate(database);
	}
}